package com.ssk.controller;

import com.ssk.model.Order;
import com.ssk.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("findAll")
    public List<Order> findAll(){
        return orderService.findAll();
    }

    @RequestMapping("findById")
    public Order findById(@RequestParam("id")int id){
        return orderService.findById(id);
    }

    @RequestMapping("findByItemId")
    public List<Order> findByItemId(@RequestParam("itemId")String itemId){
        return orderService.findByItemId(itemId);
    }

    @RequestMapping("save")
    public boolean save(@RequestBody Order order){
        return orderService.save(order);
    }

    @RequestMapping("hello")
    public String hello(){
        return "hello";
    }


}
